﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Strom.Core.Network
{
    public class PacketWriter : BinaryWriter
    {
        public PacketWriter() : base(new MemoryStream())
        {
        }

        public Packet CompilePacket(byte id)
        {
            var packet = new Packet(id, (int) BaseStream.Length);
            BaseStream.Seek(0, 0);
            byte[] buffer = new byte[packet.DatasLenght];
            BaseStream.Read(buffer, 0, buffer.Length);
            packet.SetDatas(buffer);

            return packet;
        }
    }
}
